/**
  ******************************************************************************
  * @file    Bsp/menu.c 
  * @author  zlf
  * @version V1.0.0
  * @date    2016-04-05
  * @brief   menu.c module
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
	#include "Menu.h"
	#include "MenuDisp.h"
	#include "MenuSecret.h"
	#include "MenuSuper.h"

/* Private define ------------------------------------------------------------*/
#define KEY_NOKEY 0

/* Private function prototypes -----------------------------------------------*/
void NullFuncVoid(void){}
void NullFuncU8(u8 Key){}

/* Private variables ---------------------------------------------------------*/
u8 GlobalMenuUpdateTime = 0;
Language_TypeDef Global_lang = ENGLISH ;
Menu_Para Global_Menu_Para = {0, KEY_NOKEY,ENGLISH};
BarMenu Bar_Menu_Para;
DigitSetMenu Digit_Set_Menu_Para;
TimeSet Time_Set_Para;


const Menu MenuFrame[] = 
{

	//  		|--------------------------------------------->FrameID
	//  		|         
	//  		|                    	|------------------------------>MenuInit
	//  		|                    	|           	   		|------------------------->UpdateParam
	//  		|                    	|              			|              			|------------------->FrameKeyDown
	//  		|                    	|              			|              			|                 		|------------>FrameKeyUp
	//  		|                    	|              			|              			|                 		|
	//-- brand content text ----------------------------------------
	{		ID_FRM_BRAND,			BrandInit,			BrandParaUpdate,		NullFuncU8,				NullFuncU8   },
	{		ID_FRM_INIT,			InitInit,			InitParaUpdate,			NullFuncU8,				NullFuncU8 	 },

	//-- the first layer -------------------------------------------
	{		ID_FRM_STOP,			StopInit,			StopParaUpdate,			StopKeyDown,			NullFuncU8 	 },

	{		ID_FRM_PW,				PwEnterInit,		NullFuncVoid,			PwEnterKeyDown,			NullFuncU8 	 },

	{		ID_FRM_SET,				SetInit,			NullFuncVoid,			SetKeyDown,				NullFuncU8 	 },

	{		ID_FRM_WEIGHT0,			Weight0Init,		Weight0Update,			Weight0KeyDown,			NullFuncU8 	 },
	{		ID_FRM_ZERO,			ZeroInit,			ZeroUpdate,				ZeroKeyDown,			NullFuncU8 	 },
	{		ID_FRM_POS,				PosInit,			NullFuncVoid,			PosKeyDown,				NullFuncU8 	 },
	{		ID_FRM_SPEEDMODEL,		SpeedModelInit, 	NullFuncVoid,			SpeedModelKeyDown,		NullFuncU8	 },
	{		ID_FRM_FLTGEAR,			FltGearInit,		NullFuncVoid,			FltGearKeyDown,			NullFuncU8 	 },
	{		ID_FRM_LOADRELEASE,		LoadReleaseInit,	NullFuncVoid,		    LoadReleaseKeyDown,		NullFuncU8 	 },
	{		ID_FRM_MAXSPEED,		MaxSpeedInit,		NullFuncVoid,			MaxSpeedKeyDown,		NullFuncU8 	 },
	{		ID_FRM_COUNT_REST,		CountResetInit,		CountResetUpdate,		CountResetKeyDown,		NullFuncU8 	 },
	{		ID_FRM_GEAR,			GearInit,			NullFuncVoid,			GearKeyDown,			NullFuncU8 	 },
	{		ID_FRM_HANDLE_FIRST,	HandleFirstInit,	NullFuncVoid,		    HandleFirstKeyDown,		NullFuncU8 	 },
	{		ID_FRM_SLEEP,			SleepInit,			NullFuncVoid,			SleepKeyDown,			NullFuncU8 	 },
	{		ID_FRM_PW0,				Pw0Init,			NullFuncVoid,			Pw0KeyDown,				NullFuncU8 	 },
	{		ID_FRM_MACHINEMODEL,	MachineModelInit,	NullFuncVoid,		    MachineModelKeyDown,	NullFuncU8 	 },
	
	{		ID_FRM_POS_Stop_P,		PosStopPInit,		PosLimPUpdate,			PosStopPKeyDown,		NullFuncU8 	 },
	{		ID_FRM_POS_Stop_N,		PosStopNInit,		PosLimPUpdate,			PosStopNKeyDown,		NullFuncU8 	 },


	{		ID_FRM_PW_WRONG,		PwEnterWrongInit,	NullFuncVoid,			PwEnterWrongKeyDown,	NullFuncU8 	 },
	{		ID_FRM_PW0_AG,			PwEnterAgInit,		NullFuncVoid,			Pw0AgKeyDown,			NullFuncU8 	 },
	{		ID_FRM_PW1_AG,			PwEnterAgInit,		NullFuncVoid,			Pw1AgKeyDown,			NullFuncU8 	 },
	{		ID_FRM_PW2_AG,			PwEnterAgInit,		NullFuncVoid,			Pw2AgKeyDown,			NullFuncU8 	 },
	{		ID_FRM_SECRET,			SecretInit,			NullFuncVoid,			SecretKeyDown,			NullFuncU8 	 },

	{		ID_FRM_PW_RESET,		PwResetInit,		NullFuncVoid,			PwResetKeyDown,			NullFuncU8 	 },
	{		ID_FRM_LOGDISP,	        LogDisplayInit,     NullFuncVoid,		    LogDisplayKeyDown,	    NullFuncU8 	 },
	{		ID_FRM_CLCIKSPEED,		ClickSpeedInit,		NullFuncVoid,			ClickSpeedKeyDown,		NullFuncU8 	 },
	{		ID_FRM_DEADBAND,		DeadBandInit, 	    NullFuncVoid,			DeadBandKeyDown,		NullFuncU8	 },
	{		ID_FRM_ASSEMBLY,		AssemblyInit, 	    NullFuncVoid,			AssemblyKeyDown,		NullFuncU8	 },
	{		ID_FRM_WEIGHTPROTECT,	WeightProtectInit,	NullFuncVoid,			WeightProtectKeyDown,	NullFuncU8 	 },
	{		ID_FRM_TOUCHDOWNWEI,	TouchDownWeightInit,NullFuncVoid,		    TouchDownWeightKeyDown,	NullFuncU8 	 },
	{		ID_FRM_LIMITSPEED,		LimitSpeedInit, 	NullFuncVoid,			LimitSpeedKeyDown,		NullFuncU8	 },
	{		ID_FRM_SWITCHBALANCE,	SwitchBalanceInit,	NullFuncVoid,			SwitchBalanceKeyDown,	NullFuncU8 	 },
	{		ID_FRM_LANG,			LanguageSetInit,	NullFuncVoid,			LanguageSetKeyDown,		NullFuncU8 	 },
	{		ID_FRM_SYSTEMTIMESET,	SystemTimeSetInit,	NullFuncVoid,			SystemTimeSetKeyDown,	NullFuncU8 	 },

	//super
	{		ID_FRM_SUPER,			SuperInit,			NullFuncVoid,			SuperKeyDown,			NullFuncU8 	 },
	{		ID_FRM_WEIGHT,			WeightInit,			NullFuncVoid,			WeightKeyDown,			NullFuncU8 	 },
	{		ID_FRM_AUTOTEST,		AutoTestingInit,	AutoTestingUpdate,		AutoTestingKeyDown,		NullFuncU8 	 },
	{		ID_FRM_TESTCNT,			TestCountInit,		NullFuncVoid,		    TestCountKeyDown,		NullFuncU8 	 },
	{		ID_FRM_TOTAL_REST,		TotalRestInit,		TotalRestUpdate,		TotalRestKeyDown,		NullFuncU8 	 },
	{		ID_FRM_ANGLE,			AngleInit,			NullFuncVoid,			AngleKeyDown,			NullFuncU8 	 },
	{		ID_FRM_RADIUS,			RadiusInit,			NullFuncVoid,			RadiusKeyDown,			NullFuncU8 	 },
	{		ID_FRM_RATIO,			RatioInit,			NullFuncVoid,			RatioKeyDown,			NullFuncU8 	 },
	{		ID_FRM_FACTORY,	        FactoryInit,        NullFuncVoid,		    FactoryKeyDown,	        NullFuncU8 	 },
	
	
	{		ID_FRM_LOADCALIB, 		LoadCalibInit,		LoadCalibUpdate,		LoadCalibKeyDown, 		NullFuncU8	 },
	{		ID_FRM_WIRELOOSEN,		WireLoosenInit, 	WireLoosenUpdate,		WireLoosenKeyDown,		NullFuncU8	 },

	{		ID_FRM_OVERLOAD, 		OverLoadInit,		NullFuncVoid,			OverLoadKeyDown, 		NullFuncU8	 },
	{		ID_FRM_LOADLOST, 		LoadLostInit,		NullFuncVoid,			LoadLostKeyDown, 		NullFuncU8	 },
	
	
	{		ID_FRM_PITCH, 		    PitchInit,			NullFuncVoid,			PitchKeyDown, 			NullFuncU8	 },
	{		ID_FRM_ROLL, 			RollInit,			NullFuncVoid,			RollKeyDown, 			NullFuncU8	 },
	
	{		ID_FRM_V1_UP, 			V1MaxUPInit,		NullFuncVoid,		    V1MaxUPKeyDown, 		NullFuncU8	 },
	{		ID_FRM_V1_DN, 			V1MaxDNInit,		NullFuncVoid,		    V1MaxDNKeyDown, 		NullFuncU8	 },
	{		ID_FRM_V2_UP, 			V2MaxUPInit,		NullFuncVoid,		    V2MaxUPKeyDown, 		NullFuncU8	 },
	{		ID_FRM_V2_DN, 			V2MaxDNInit,		NullFuncVoid,		    V2MaxDNKeyDown, 		NullFuncU8	 },
	{		ID_FRM_BALANCE_UP, 		BalanceMaxUPInit,	NullFuncVoid,		    BalanceMaxUPKeyDown, 	NullFuncU8	 },
	{		ID_FRM_BALANCE_DN, 		BalanceMaxDNInit,	NullFuncVoid,		    BalanceMaxDNKeyDown, 	NullFuncU8	 },

	
	{		ID_FRM_SLOW_UP,			ClickSpeedSlowUPInit,	NullFuncVoid,	ClickSpeedSlowUPKeyDown, 	NullFuncU8	 },
	{		ID_FRM_SLOW_DN,			ClickSpeedSlowDNInit,	NullFuncVoid,	ClickSpeedSlowDNKeyDown, 	NullFuncU8	 },
	{		ID_FRM_SLOW_ACC_UP,		ClickAccSlowUPInit,	    NullFuncVoid,	ClickAccSlowUPKeyDown, 	    NullFuncU8	 },
	{		ID_FRM_SLOW_ACC_DN,		ClickAccSlowDNInit,	    NullFuncVoid,	ClickAccSlowDNKeyDown, 	    NullFuncU8	 },
	{		ID_FRM_FAST_UP,			ClickSpeedFastUPInit,	NullFuncVoid,	ClickSpeedFastUPKeyDown, 	NullFuncU8	 },
	{		ID_FRM_FAST_DN,			ClickSpeedFastDNInit,	NullFuncVoid,	ClickSpeedFastDNKeyDown, 	NullFuncU8	 },
	{		ID_FRM_FAST_ACC_UP,		ClickAccFastUPInit,	    NullFuncVoid,	ClickAccFastUPKeyDown,   	NullFuncU8	 },
	{		ID_FRM_FAST_ACC_DN,		ClickAccFastDNInit,	    NullFuncVoid,	ClickAccFastDNKeyDown,   	NullFuncU8	 },
	{		ID_FRM_WIFI_CONTROL,	WifiControlInit,	    NullFuncVoid,	WifiControlKeyDown, 	    NullFuncU8	 },

	{		ID_FRM_PICKUP,			PickUpInit,	       NullFuncVoid,	       PickUPKeyDown, 	         NullFuncU8	 },
	{		ID_FRM_PICKUP_UP,		PickUpUPInit,	   PosLimPUpdate,	       PickUpUPKeyDown, 	     NullFuncU8	 },
	{		ID_FRM_PICKUP_DN,		PickUpDNInit,	   PosLimPUpdate,	       PickUpDNKeyDown, 	     NullFuncU8	 },
	{		ID_FRM_PICKUP_SPEED_UP,	PickUPSpeedUPInit,   NullFuncVoid,	       PickUPSpeedUPKeyDown, 	 NullFuncU8	 },
	{		ID_FRM_PICKUP_SPEED_DN,	PickUPSpeedDNInit,   NullFuncVoid,	       PickUPSpeedDNKeyDown, 	 NullFuncU8	 },
	{		ID_FRM_PICKUP_DEADUP,	PickUPDEADHandUPInit,NullFuncVoid,	       PickUPDEADHandUPKeyDown, NullFuncU8	 },
	{		ID_FRM_PICKUP_DEADDN,	PickUPDEADHandDNInit,NullFuncVoid,	       PickUPDEADHandDNKeyDown, NullFuncU8	 },
	{		ID_FRM_PICKUP_BAL_UP,	PickUPDEADBalanceUPInit,NullFuncVoid,	   PickUPDEADBalanceUPKeyDown,NullFuncU8 },
	{		ID_FRM_PICKUP_BAL_DN,	PickUPDEADBalanceDNInit,NullFuncVoid,	   PickUPDEADBalanceDNKeyDown, NullFuncU8},
	{		ID_FRM_PUTDOWN,			PutDownInit,	   NullFuncVoid,	       PutDownKeyDown, 	         NullFuncU8	 },
	{		ID_FRM_PUTDOWN_UP,		PutDownUPInit,	   PosLimPUpdate,	       PutDownUPKeyDown, 	     NullFuncU8	 },
	{		ID_FRM_PUTDOWN_DN,		PutDownDNInit,	   PosLimPUpdate,	       PutDownDNKeyDown, 	     NullFuncU8	 },
	{		ID_FRM_PUTDOWN_SPEED_UP,PutDownSpeedUPInit,  NullFuncVoid,	       PutDownSpeedUPKeyDown, 	 NullFuncU8	 },
	{		ID_FRM_PUTDOWN_SPEED_DN,PutDownSpeedUPInit,  NullFuncVoid,	       PutDownSpeedUPKeyDown, 	 NullFuncU8	 },
	{		ID_FRM_PUTDOWN_DEADUP,	PutDownDEADHandUPInit,NullFuncVoid, 	   PutDownDEADHandUPKeyDown, NullFuncU8  },
	{		ID_FRM_PUTDOWN_DEADDN,	PutDownDEADHandDNInit,NullFuncVoid, 	   PutDownDEADHandDNKeyDown, NullFuncU8  },
	{		ID_FRM_PUTDOWN_BAL_UP,	PutDownDEADBalanceUPInit,NullFuncVoid,	   PutDownDEADBalanceUPKeyDown,NullFuncU8},
	{		ID_FRM_PUTDOWN_BAL_DN,	PutDownDEADBalanceDNInit,NullFuncVoid,	   PutDownDEADBalanceDNKeyDown,NullFuncU8},

	{		ID_HANDMODE_UP,			HandModeUPInit,	   NullFuncVoid,	    HandModeUPKeyDown, 	         NullFuncU8	 },
	{		ID_HANDMODE_DN,			HandModeDNInit,	   NullFuncVoid,	    HandModeDNKeyDown, 	         NullFuncU8	 },
	{		ID_BALANCEODE_UP,		BalanceModeUPInit, NullFuncVoid,	    BalanceModeUPKeyDown, 	     NullFuncU8	 },
	{		ID_BALANCEODE_DN,		BalanceModeDNInit, NullFuncVoid,	    BalanceModeDNKeyDown, 	     NullFuncU8	 },

	{		ID_FIT_SWITCH,			FitSwitchInit,	    NullFuncVoid,	    FitSwitchKeyDown, 	         NullFuncU8	 },
	{		ID_FIT_DECEPOINT_UP,	FitDecePointUPInit,	PosLimPUpdate,	    FitDecePointUPKeyDown, 	     NullFuncU8	 },
	{		ID_FIT_STOPPOINT_UP,    FitStopPointUPInit, PosLimPUpdate,	    FitStopPointUPKeyDown, 	     NullFuncU8	 },
	{		ID_FIT_DECEPOINT_DN,    FitDecePointDNInit,  PosLimPUpdate,	    FitDecePointDNKeyDown, 	     NullFuncU8	 },
	{		ID_FIT_STOPPOINT_DN,	FitStopPointDNInit,  PosLimPUpdate,	    FitStopPointDNKeyDown, 	     NullFuncU8	 }
	
};
void LanguageInit()
{

    //Global_Menu_Para.Language = (Language_TypeDef)tSet[TS_LANG];
}

/* Private functions ---------------------------------------------------------*/

/**
  * @brief  This function to initialise the menu relative.
  * @param  None
  * @retval None
  */
void Menu_Init( void )
{
	OLED_Init();
	Button_Init();
	LanguageInit();
	JumpFrame(ID_FRM_BRAND);
}

/**
  * @brief  This function to jump to the frameID.
  * @param  frameID, the id of frame to be jumped.
  * @retval None
  */
void JumpFrame( u8 frameID )
{
	Global_Menu_Para.CurFrameID = frameID;
	MenuFrame[ (Global_Menu_Para.CurFrameID) ].MenuInit();
}

/**
  * @brief  This function about the key action when the key pressed or released.
  * @param  None
  * @retval None
  */
void CheckKey( void )
{
	u8 Key = (u8)Key_Scan();
	tGlobal.curBtn = Key;
	if( Key != Global_Menu_Para.LastKey )
	{
		if( 0x00 != Key )
		{
			MenuFrame[ Global_Menu_Para.CurFrameID ].FrameKeyDown(Key);
			
			tGlobal.LiftSleep = 0; // weakup
			tGlobal.LiftSleepTim = 0;
			//BLED_ON;		
		}
		if( 0x00 != Global_Menu_Para.LastKey )
		{
			MenuFrame[ Global_Menu_Para.CurFrameID ].FrameKeyUp( Global_Menu_Para.LastKey );
		}
	}

	Global_Menu_Para.LastKey = Key;
	
}

/**
  * @brief  This function is to update the parameter on specific frame.
  * @param  None
  * @retval None
  */
void UpdateParam( void )
{
	MenuFrame[ Global_Menu_Para.CurFrameID ].UpdateParam();
}

/**
  * @brief  This function is about the frame management.
  * @param  None
  * @retval None
  */
void FrameManagement( void )
{
	CheckKey();
	UpdateParam();
	if( ( Global_Menu_Para.CurFrameID >= ID_FRM_STOP ) &&
		( Global_Menu_Para.CurFrameID < ID_BALANCEODE_DN ))  //ID_FRM_LANG
	{
		GlobalUpdate();
	}
	
}

/**
  * @brief  This function is initialise the glcd displaying according the parameter.
  * @param  None
  * @retval None
  */
void BarMenuInit( void )
{
	//Clear the screen
	Glcd_Clear_Downhalf_Screen();

	//display the title
	Glcd_DispStringAt( *(Bar_Menu_Para.TitleItem), 
					   MENU_ORIGIN, 
					   MENU_LINE_THREE, 
					   MENU_PIXAL, 
					   GUI_TEXTMODE_NORMAL, 
					   GUI_ALIGNSTYLE_LEFT );
	
	//Display the postion of bar item
	Glcd_Set_XY_Address(MENU_ORIGIN,MENU_LINE_FOUR);
	Glcd_Write_Decimal( (Bar_Menu_Para.Where + 1) , GUI_TEXTMODE_NORMAL );

	//Display the bar item
	Glcd_DispStringAt( *(Bar_Menu_Para.DispItem + Bar_Menu_Para.Where), 
					   MENU_BAR_POSITION, 
					   MENU_LINE_FOUR, 
					   MENU_PIXAL, 
					   GUI_TEXTMODE_NORMAL, 
					   GUI_ALIGNSTYLE_LEFT );
}

/**
  * @brief  This function is bar movement when CANCEL key pressed.
  * @param  None
  * @retval None
  */
void BarMenuDown( void )
{			
	Bar_Menu_Para.Where = ( Bar_Menu_Para.Where + 1 ) % Bar_Menu_Para.ItemNum;

	//Clear the second line
	Glcd_Clear_Line( MENU_ORIGIN, MENU_LINE_FOUR, MENU_PIXAL );

	//Display the postion of bar item
	Glcd_Set_XY_Address(MENU_ORIGIN,MENU_LINE_FOUR);
	Glcd_Write_Decimal( (Bar_Menu_Para.Where + 1) , GUI_TEXTMODE_NORMAL );

	//Display the bar item
	Glcd_DispStringAt( *(Bar_Menu_Para.DispItem + Bar_Menu_Para.Where), 
					   MENU_BAR_POSITION, 
					   MENU_LINE_FOUR, 
					   MENU_PIXAL, 
					   GUI_TEXTMODE_NORMAL, 
					   GUI_ALIGNSTYLE_LEFT );
}

/**
  * @brief  This function is bar movement when OK key pressed.
  * @param  None
  * @retval None
  */
void BarMenuUp( void )
{			
	Bar_Menu_Para.Where = ( Bar_Menu_Para.ItemNum + Bar_Menu_Para.Where - 1 ) 
							% Bar_Menu_Para.ItemNum;

	//Clear the second line
	Glcd_Clear_Line( MENU_ORIGIN, MENU_LINE_FOUR, MENU_PIXAL );
	//Display the postion of bar item
	Glcd_Set_XY_Address(MENU_ORIGIN,MENU_LINE_FOUR);
	Glcd_Write_Decimal( (Bar_Menu_Para.Where + 1) , GUI_TEXTMODE_NORMAL );
	//Display the bar item
	Glcd_DispStringAt( *(Bar_Menu_Para.DispItem + Bar_Menu_Para.Where), 
					   MENU_BAR_POSITION, 
					   MENU_LINE_FOUR, 
					   MENU_PIXAL, 
					   GUI_TEXTMODE_NORMAL, 
					   GUI_ALIGNSTYLE_LEFT );
}

/**
  * @brief  This function is called in the digit set menu when "CANCEL" is pressed.
  * @param  None
  * @retval None
  */
void DigitSetMenuInit( void )
{
	switch( Digit_Set_Menu_Para.DigitSettingNum )
	{
		case STATE_HUNDRED_SETTING:
			Glcd_Set_XY_Address( MENU_DIGIT_HUND_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.HundDigit , GUI_TEXTMODE_REVERSE );
			Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_NORMAL );
			Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_NORMAL );
			break;
		case STATE_DECIMAL_SETTING:
			Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_REVERSE );
			Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_NORMAL );
			break;
		case STATE_INDIVIDUAL_SETTING:
			Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_REVERSE );
		default:
			break;
	}
}

/**
  * @brief  This function is called in the digit set menu when "OK" is pressed.
  * @param  None
  * @retval None
  */
void DigitSetMenuDown( void )
{
	switch( Digit_Set_Menu_Para.DigitSettingIndex )
	{
		case STATE_HUNDRED_SETTING:
			Digit_Set_Menu_Para.DigitSettingIndex = STATE_DECIMAL_SETTING;
			Glcd_Set_XY_Address( MENU_DIGIT_HUND_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.HundDigit , GUI_TEXTMODE_NORMAL );
			Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_REVERSE );
			break;
		case STATE_DECIMAL_SETTING:
			Digit_Set_Menu_Para.DigitSettingIndex = STATE_INDIVIDUAL_SETTING;
			Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_NORMAL );
			Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_REVERSE );
			break;
		case STATE_INDIVIDUAL_SETTING:
			switch( Digit_Set_Menu_Para.DigitSettingNum )
			{
				case STATE_HUNDRED_SETTING:
					Digit_Set_Menu_Para.DigitSettingIndex = STATE_HUNDRED_SETTING;
					Glcd_Set_XY_Address( MENU_DIGIT_HUND_POS, MENU_LINE_FOUR );
					Glcd_Write_Digit( Digit_Set_Menu_Para.HundDigit , GUI_TEXTMODE_REVERSE );
					Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
					Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_NORMAL );					
					break;
				case STATE_DECIMAL_SETTING:
					Digit_Set_Menu_Para.DigitSettingIndex = STATE_DECIMAL_SETTING;
					Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
					Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_REVERSE );
					Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
					Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_NORMAL );					
					break;
				default:
					break;
			}	
			break;		
		default:
			break;
	}
}

/**
  * @brief  This function is called in the digit set menu when "CANCEL" is pressed.
  * @param  None
  * @retval None
  */
void DigitSetMenuUp( void )
{
	switch( Digit_Set_Menu_Para.DigitSettingIndex )
	{
		case STATE_HUNDRED_SETTING:
			//Increment the hundDigit
			if( Digit_Set_Menu_Para.HundDigit < Digit_Set_Menu_Para.HundUpperLimit )
			{
				++Digit_Set_Menu_Para.HundDigit;
			}
			else
			{
				Digit_Set_Menu_Para.HundDigit = Digit_Set_Menu_Para.HundLowerLimit;
			}

			//display the hundred digit
			Glcd_Set_XY_Address( MENU_DIGIT_HUND_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.HundDigit , GUI_TEXTMODE_REVERSE );
			break;

		case STATE_DECIMAL_SETTING:
			//Increment the deciDigit
			if( Digit_Set_Menu_Para.DeciDigit < Digit_Set_Menu_Para.DeciUpperLimit )
			{
				++Digit_Set_Menu_Para.DeciDigit;
			}
			else
			{
				Digit_Set_Menu_Para.DeciDigit = Digit_Set_Menu_Para.DeciLowerLimit;
			}

			//display the decimal digit
			Glcd_Set_XY_Address( MENU_DIGIT_DECI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.DeciDigit , GUI_TEXTMODE_REVERSE );	
			break;

		case STATE_INDIVIDUAL_SETTING:
			//Increment the individual digit
			if( Digit_Set_Menu_Para.IndiDigit < Digit_Set_Menu_Para.IndiUpperLimit )
			{
				++Digit_Set_Menu_Para.IndiDigit;
			}
			else
			{
				Digit_Set_Menu_Para.IndiDigit = Digit_Set_Menu_Para.IndiLowerLimit;
			}

			//display the individual digit
			Glcd_Set_XY_Address( MENU_DIGIT_INDI_POS, MENU_LINE_FOUR );
			Glcd_Write_Digit( Digit_Set_Menu_Para.IndiDigit , GUI_TEXTMODE_REVERSE );	
			break;

		default:
			break;			
	}
}


